//
//  RegisterTwoCollectionViewCell.m
//  MingJiangApp
//
//  Created by wangliang on 15/3/11.
//  Copyright (c) 2015年 wangliang. All rights reserved.
//

#import "RegisterTwoCollectionViewCell.h"

@interface RegisterTwoCollectionViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *codeLabel;

@property (weak, nonatomic) IBOutlet UITextField *codeTextField;

@end

@implementation RegisterTwoCollectionViewCell

- (void)awakeFromNib {
    // Initialization code
    self.codeTextField.keyboardType = UIKeyboardTypeNumberPad;
    [self refreshView];
}

- (void)refreshView {
    
    NSString *code = [[NSUserDefaults standardUserDefaults] valueForKey:@"code"];
    self.codeLabel.text = [NSString stringWithFormat:@"%@",code];
}

- (IBAction)next:(id)sender {
    
    [self.codeTextField resignFirstResponder];
    NSString *code = [[NSUserDefaults standardUserDefaults] valueForKey:@"code"];
    if ([self.codeTextField.text isEqual:code.description]) {
        
        if ([self.delegate respondsToSelector:@selector(registerViewGoToNext:withObject:)]) {
            
            [self.delegate registerViewGoToNext:@"验证码" withObject:self];
        }
    }else {
        
        [[DMCAlertCenter defaultCenter] postAlertWithMessage:@"输入验证不对或已过期"];
    }
    
}

- (IBAction)goBack:(id)sender {
    
    if ([self.delegate respondsToSelector:@selector(registerViewGoToBack:withObject:)]) {
        
        [self.delegate registerViewGoToBack:@"" withObject:self];
    }
}

- (IBAction)cancel:(id)sender {
    
    if ([self.delegate respondsToSelector:@selector(registerViewCancel:withObject:)]) {
        
        [self.delegate registerViewCancel:@"" withObject:self];
    }
}


@end
